.search-country-selector {
    position: relative;
    align-self: flex-end;
    display: flex;
    align-items: center;
    height: 46px; // 48px - 2px border
}

.search-country-selector-button {
    @include body-3-bold;
    background-color: #fff;
    cursor: pointer;
    font-weight: bold;
    color: $blue-90;
    height: 32px;
    padding: 0 16px;

    margin-right: 8px;
    display: flex;
    justify-content: center;
    align-items: center;

    &:hover {
        background-color: $gray-10;
    }

    &.search-country-selector-button--is-open {
        background-color: $accent-pale-blue;
    }

    @include sm-only {
        width: 32px;
        background-color: $blue-10;
    }
}

.search-country-selector-button__icon {
    font-size: 12px;
    margin-right: 6px;

    @include sm-only {
        margin-right: 0;
        font-size: 14px;
        line-height: 14px;
    }
}

.search-country-selector-button__text {
    @include sm-only {
        display: none;
    }
}

.search-country-selector-search-container {
    position: relative;
    margin-bottom: 16px;
    svg {
        width: 14px;
        height: 14px;
    }
}

.search-country-selector__search-icon {
    color: $gray-70;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    height: 12px;
}

.search-country-selector__clear-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0;
    background-color: transparent;
    color: $gray-70;
    &:hover {
        color: $gray-90;
    }
}

.search-country-selector-switch {
    margin-bottom: 16px;
    label {
        @include label-2-medium;
        color: $gray-80;
        white-space: wrap;
    }
}

.search-country-selector-search-input {
    background-color: #fff;
    border: 1px solid $gray-20;
    border-radius: 0;
    height: 32px;
    line-height: 32px;
    font-size: 13px;
    padding-left: 32px;
    padding-right: 32px;
    width: 100%;

    &:focus {
        outline: none;
        border-color: $blue-30;
    }

    &:placeholder-shown,
    &::placeholder {
        color: $gray-60;
    }

    @include sm-only {
        // Prevents auto-zoom on Safari
        font-size: 16px;
    }
}

.search-country-selector-list-container {
    background-color: #fff;
    padding: 16px;
    // wide enough for the toggle label text not to wrap
    width: 380px;
    margin-top: 8px;
    box-shadow: 4px 0 30px 0 #00000020;

    @include sm-only {
        width: calc(100vw - 48px);
    }
}

.search-country-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.search-country-selector__heading {
    color: $gray-70;
    margin: 0;
}

.search-country-selector-close-button {
    background-color: transparent;
    border: 1px solid $gray-20;
    border-radius: 16px;
    width: 32px;
    height: 32px;
    line-height: 13.5px;
    padding: 0;
    cursor: pointer;
    color: $gray-80;
    display: flex;
    justify-content: center;
    align-items: center;
    &:focus {
        border-color: $gray-70;
        outline: none;
    }
    &:hover {
        background-color: $gray-10;
        border-color: $gray-10;
    }
    svg {
        height: 13px;
        width: 13px;
        margin-bottom: 1px;
    }
}

.search-country-selector-list {
    list-style: none;
    max-height: 300px;
    overflow-y: scroll;
    &:focus-visible {
        outline: 1px solid $gray-60;
    }
}

.search-country-selector-list__item {
    @include body-3-medium;
    border-bottom: 1px solid $gray-10;
    position: relative;
    transition: 100ms background-color;
    width: 100%;
    display: block;
    padding: 8px 0;
    color: $blue-90;
    display: flex;
    align-items: center;

    &:last-child {
        border-bottom: none;
    }

    &:hover {
        background-color: $blue-10;
    }

    // Override global focus styles.
    &:focus-visible {
        outline: none;
    }

    // React Aria ListBoxItem focus styles.
    &[data-focused] {
        background-color: $blue-10;
        outline: none;
    }

    img {
        margin: 0 8px;
        outline: 1px solid $blue-20;
    }

    input {
        @include owid-checkbox;
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;
    }
}

.search-country-selector-list__item--selected {
    background-color: $accent-pale-blue;
    &:hover {
        background-color: $accent-pale-blue;
    }
}
